package socket;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.geom.Area;
import javax.swing.JFrame;
import javax.swing.JLabel;
import com.sun.awt.AWTUtilities;

public class test extends Thread{
private JFrame log = new JFrame();
//private JDialog jlog = new JDialog();
private JLabel label;
private JLabel label1;
private Graphics2D g2d;
private BasicStroke bs;
private int t = 0;
private int a;
private int b;
public test(){
	float []f={1f,1f};
	bs=new BasicStroke(1,BasicStroke.JOIN_ROUND,BasicStroke.JOIN_ROUND,10f,f,10f);
	
	
    float[] dash1 = {1.0f};

    bs = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
	
	log = new JFrame()
	{
		
		private static final long serialVersionUID = 1L;

		@Override
		public void paint(Graphics g) {
			super.paint(g);
//			g2d=(Graphics2D)g;
//			g2d.setStroke(bs);
//			g2d.setColor(Color.black);
//			g2d.draw(new Rectangle(a -400,a,b,b));
//			g2d.draw(new Rectangle(a-1-400,a-1,b+2,b+2));
//			g2d.draw(new Rectangle(a-2-400,a-2,b+4,b+4));
//			
		}
	}
	;
	
	
//	log.setAlwaysOnTop(true);
	log.setUndecorated(true);
//
//	AWTUtilities.setWindowOpaque(log, false){
//		
//	}
	
//	AWTUtilities.setWindowShape(log, new Area(new Rectangle(0,0,1000,500)));
	
//	AWTUtilities.setWindowShape(log,new Area(new Rectangle(0,0,500,500)));
	
//	AWTUtilities.setWindowOpacity(log, 0.1f);
	
	log.setBounds(0, 0, 1400,900);
	log.setLayout(null);
	
//	jlog.setUndecorated(true);
//	AWTUtilities.setWindowOpaque(log, false);
//	jlog.setBounds(0, 50, 1200, 50);
//	jlog.setLayout(null);
	
	label = new JLabel()
	{
	
	private static final long serialVersionUID = 1L;

	@Override
	public void paint(Graphics g) {
		super.paint(g);
		g2d=(Graphics2D)g;
		g2d.setStroke(bs);
		g2d.setColor(Color.blue);
		g2d.setClip(0, 0, 100, 200);
//		g2d.draw(new Rectangle(a,a,b,b));
//		g2d.draw(new Rectangle(a-1,a-1,b+2,b+2));
//		g2d.draw(new Rectangle(a-2,a-2,b+4,b+4));
		g2d.drawRect(a,a,b,b);
		g2d.drawRect(a-1,a-1,b+2,b+2);
		g2d.drawRect(a-2,a-2,b+4,b+4);
	}
};

label1 = new JLabel()
{

private static final long serialVersionUID = 1L;

@Override
public void paint(Graphics g) {
	super.paint(g);
	g2d=(Graphics2D)g;
	g2d.setStroke(bs);
	g2d.setColor(Color.black);
	g2d.draw(new Rectangle(a -400,a,b,b));
	g2d.draw(new Rectangle(a-1-400,a-1,b+2,b+2));
	g2d.draw(new Rectangle(a-2-400,a-2,b+4,b+4));
//	g2d.drawRect(a,a,b,b);
//	g2d.drawRect(a-1,a-1,b+2,b+2);
//	g2d.drawRect(a-2,a-2,b+4,b+4);

}
};
	
	label1.setBounds(410, 0, 1400, 450);

	label.setBounds(0, 0, 1400, 800);
	
	log.add(label1);
	log.add(label);
	
//	jlog.add(label1);
//	jlog.add(label);
//	jlog.setVisible(true);
	log.setVisible(true);
	
}



public static void main(String[] args) {
	test t = new test();
	t.start();
}



@Override
public void run() {
	// TODO Auto-generated method stub
	while(true){
		try {
			Thread.sleep(20);
			if(a < 400){
				a+=10;
			}else{
				a  = 0;
			}
			
			if(b<900){
				b+=10;
			}else{
				b=0;
			}
			t++;
//			log.setBounds(100+t, 20 + t, 3, 100);
			if(t > 800){
				t = 0;
			}
//			a = 200;
//			b = 400;
			
			
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
//		label.repaint(0,0,10,10);
//		log.repaint(0,0,10,10);
//		log.repaint();
//		log.update(log.getGraphics());
		label.updateUI();
//		label1.updateUI();
//		label.updateUI();
//		label1.updateUI();
//		log.repaint(0,0,200,100);
//		jlog.repaint();
	}
}
}
